package gentle.controller;


import com.baomidou.mybatisplus.plugins.Page;
import gentle.base.BaseController;
import gentle.entity.RootImageInfo;
import gentle.entity.SearchRootImageInfo;
import gentle.factory.PageFactory;
import gentle.service.IDentalImageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;

/**
 * 质量管理控制器
 *
 */
@Controller
@RequestMapping("/rootOrthodontics")
public class RootOrthodonticsImageController extends BaseController {
    @Autowired
    IDentalImageService service;

    /**
     * 正畸影像列表
     */
    @RequestMapping(value = "/list/{reservationsId}")
    @ResponseBody
    public Object list(SearchRootImageInfo info, @PathVariable String reservationsId) {
        Page<RootImageInfo> page = new PageFactory<RootImageInfo>().defaultPage();
        try {
            info.setReservationsId(reservationsId);
            info.setStartIndex(page.getSize() * (page.getCurrent() - 1));
            info.setLimitIndex(page.getSize());
            page.setCurrent(0);
            List<RootImageInfo> list = service.selectPageListByOrthodontics(page, info);
            if (list.size() == 0) {
                info.setStartIndex(0);
                list = service.selectPageListByOrthodontics(page, info);
            }
            page.setTotal(service.getOrthodonticsPageCount(page, info));
            page.setRecords(list);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return super.packForBT(page);
    }

//    /**
//     * 质量检测正畸影像列表
//     */
//    @RequestMapping(value = "/rootList")
//    @ResponseBody
//    public Object rootList(SearchRootImageInfo info, HttpServletRequest request) {
//        Page<RootImageInfo> page = new PageFactory<RootImageInfo>().defaultPage();
//        try {
//            info.setStartIndex(page.getSize() * (page.getCurrent() - 1));
//            info.setLimitIndex(page.getSize());
//            page.setCurrent(0);
//            List<RootImageInfo> list = service.selectPageListByOrthodontics1(page, info);
//            if (list.size() == 0) {
//                info.setStartIndex(0);
//                list = service.selectPageListByOrthodontics1(page, info);
//            }
//            page.setTotal(service.getOrthodonticsPageCount1(page, info));
//            page.setRecords(list);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//        return super.packForBT(page);
//    }
//
    //获取正畸 图片
    @RequestMapping(value = "/getImgcancel", method = RequestMethod.POST)
    @ResponseBody
    public List<RootImageInfo> getImgcancel(String num, String iconType, String classification) throws Exception {
        return service.getImgcancel(num,  iconType,  classification);
    }

}
